package com.gmrz.webauthn.protocol.v1.schema;

import com.google.gson.annotations.SerializedName;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public enum AttestationConveyancePreference {
    @SerializedName("none")
    NONE("none"),

    @SerializedName("indirect")
    INDIRECT("indirect"),

    @SerializedName("direct")
    DIRECT("direct");


    String mValue;

    private static final Logger LOG = LogManager.getLogger(AttestationConveyancePreference.class);

    AttestationConveyancePreference(String mValue) {
        this.mValue = mValue;
    }

    String getValue() {
        return this.mValue;
    }

    public static AttestationConveyancePreference forName(String name) {
        for (AttestationConveyancePreference preference : values()) {
            if (preference.getValue().equalsIgnoreCase(name)) {
                return preference;
            }
        }

        String errorMsg = " AttestationConveyancePreference has invalid value : " + (name.trim().equals("") ? "EMPTY" : name);
        LOG.error(errorMsg);
        throw new IllegalArgumentException(errorMsg);
    }
}
